home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_olv_door_timed.cog < prev    next >
Text File  |  1999-11-15  |  7KB  |  305 lines

  1. # Jones 3D Cog Script
  2. #
  3. # olv_door_timed.cog
  4. #
  5. # [DS]
  6. #
  7. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  8. # ========================================================================================
  9.  
  10. symbols
  11.    message  startup
  12.    message  activate      
  13.    message    arrived
  14.    message  blocked
  15.    message    entered
  16.    message    exited
  17.    message  timer
  18.    
  19.     thing        ghostcampos
  20.     thing        cam_targ                        nolink  
  21.     thing        switch0
  22.     thing        switch1
  23.     thing        switch2
  24.     thing        door0
  25.     thing        door1
  26.     sector    room0    
  27.     sector    doorjamb
  28.  
  29.     keyframe    hithead=in_reach_low.key            local
  30.     sector    doorsec0                        local
  31.     sector    doorsec1                        local
  32.     sound        stopsnd=nub_stonedoor_stop_c.wav        local
  33.     sound        ungh=inxj018a.wav                    local
  34.     thing        player                        local
  35.     flex        waittime=60.0                    local
  36.     int        closed=0                        local
  37.     int        curcam                        local
  38.     int        solved=0                        local
  39.     int        dr1_open=0                        local
  40.     int        in_jamb=0                        local
  41.     sound        music0=mus_gen_indy_B_motif1.wav        local
  42.     cog        hints
  43.     vector    vecZneg                        local
  44.     vector    vecZ                            local
  45.     flex        RandLockLines                    local
  46.     int        speak0                        local
  47.     int        lockoffset=0                    local
  48.     int        difficultylevel                    local
  49.     int        diff_time                        local
  50.     flex        curhealth=0                        local
  51.  
  52. # ---------------------------------------------------------------
  53. #        Indy Say Lines
  54. # ---------------------------------------------------------------
  55.     int    lineindex                    local # indexes sound array
  56.  
  57.     sound    in_stuck0=Inxj096.wav        local # I can't open it
  58.     sound    in_stuck1=Inxj097.wav        local # For some reason...won't open.
  59.     sound    in_stuck2=Inxj098.wav        local # It won't budge.
  60.     sound    in_stuck3=Inxj099.wav        local # Something is holding this door closed.
  61.     sound    in_stuck4=Inxj102.wav        local # must be way...don't know how.
  62.     sound    in_stuck5=Inxj090.wav        local # ...something wrong.
  63.     sound    in_stuck6=Inxj091.wav        local # Of course that didn't work.    
  64.     int    dl_newline=50            local
  65.     int    dl_oldline=50            local
  66.  
  67. end
  68. # ========================================================================================
  69. code
  70.  
  71. startup:
  72.     player = GetLocalPlayerThing();
  73.     doorsec0 = GetThingSector(door0);
  74.     doorsec1 = GetThingSector(door1);
  75.     SetSectorAdjoins(doorsec0, 0);
  76.     SetSectorAdjoins(doorsec1, 0);
  77.     return;
  78.  
  79. activate:
  80.     if((GetSenderRef() == door0) || (GetSenderRef() == door1))
  81.     {
  82.         SetActorFlags(player, 0x200000);
  83.         StopThing(Player);
  84.         StartCutscene(0);
  85.         DeselectWeaponWait(player);
  86.           PlayMode(player, 60, 0);
  87.         call randlocklines;
  88.         WaitForSound(speak0);
  89.         EndCutscene();
  90.         ClearActorFlags(player, 0x200000);
  91.         return;
  92.     }
  93.     if((GetSenderRef() == switch0) && (closed == 0))
  94.      {
  95.         closed=1;
  96.         curCam = GetCurrentCamera();
  97.         MakeMeStop();
  98.         DeselectWeaponWait(player);
  99.         StartCutscene(1);
  100.           PlayMode(player, 60, 0);
  101.         sleep(0.2);
  102.         MoveToFrame(switch0, 1, 1.0);
  103.         if(dr1_open == 0)
  104.         {
  105.             dr1_open=1;
  106.             MoveToFrame(switch1, 1, 1.0);
  107.             SetSectorAdjoins(doorsec1, 1);
  108.             MoveToFrame(door1, 1, 0.8);
  109.         }
  110.         WaitForStop(switch0);
  111.         SetCameraFocus(2, ghostcampos);
  112.         SetCameraSecondaryFocus(2, cam_targ);
  113.         SetCurrentCamera(2);
  114.         SetSectorAdjoins(doorsec0, 1);
  115.         MoveToFrame(door0, 1, 0.8);
  116.         if(solved == 1) return;
  117.         SendMessageEx(hints, user3, 1, 0, 0, 0);    #param0=1; Switch pushed.
  118.         return;
  119.     }
  120.     if((GetSenderRef() == switch1) && (dr1_open == 0))
  121.      {
  122.         dr1_open=1;
  123.         MakeMeStop();
  124.         DeselectWeaponWait(player);
  125.         StartCutscene(0);
  126.           PlayMode(player, 60, 0);
  127.         sleep(0.2);
  128.         MoveToFrame(switch1, 1, 1.0);
  129.         WaitForStop(switch1);
  130.         SetSectorAdjoins(doorsec1, 1);
  131.         MoveToFrame(door1, 1, 0.8);
  132.         sleep(0.4);
  133.         EndCutscene();
  134.         ClearActorFlags(player, 0x200000);
  135.         return;
  136.     }
  137.     if((GetSenderRef() == switch2) && (closed == 0))
  138.     {
  139.         closed=1;
  140.         MakeMeStop();
  141.         DeselectWeaponWait(player);
  142.         StartCutscene(0);
  143.           PlayMode(player, 60, 0);
  144.         sleep(0.2);
  145.         MoveToFrame(switch2, 1, 1.0);
  146.         WaitForStop(switch2);
  147.         SetSectorAdjoins(doorsec0, 1);
  148.         MoveToFrame(door0, 1, 0.8);
  149.         sleep(0.4);
  150.         EndCutscene();
  151.         ClearActorFlags(player, 0x200000);
  152.         return;
  153.     }
  154.     return;
  155.  
  156. entered:
  157.     if((GetSenderRef() == room0) && (solved == 0))
  158.     {
  159.     solved=1;
  160.     UpdateDifficulty(difficultylevel);
  161.     PlaySoundLocal(music0, 1.0, 0.0, 0x0, 0);
  162.     SendMessageEx(hints, user3, 2, 0, 0, 0);    #param0=2; Entered Room.
  163.     return;
  164.     }
  165.     if((GetSenderRef() == doorjamb) && (GetSourceRef() == player))
  166.     {
  167.     in_jamb=1;    
  168.     }
  169.     return;
  170.  
  171. exited:
  172.     if((GetSenderRef() == doorjamb) && (GetSourceRef() == player))
  173.     {
  174.     in_jamb=0;    
  175.     }
  176.     return;
  177.  
  178. arrived:
  179.     if((GetSenderRef() == door0) && (closed == 1))
  180.     {
  181.     PlaySoundThing(stopsnd, door0, 1.0, 25, 50, 0);
  182.     sleep(0.5);
  183.  
  184.  
  185.         # TO DO:  Shouldn't timer be related to difficulty?
  186.         difficultylevel=GetDifficulty();
  187.         diff_time=waittime+((5 - difficultylevel)* 10.0);
  188.         SetTimer(diff_time);
  189.  
  190.     EndCutscene();
  191.     SetCurrentCamera(curcam);
  192.     ClearActorFlags(player, 0x200000);
  193.     return;
  194.     }
  195.     if((GetSenderRef() == door0) && (closed == 2))
  196.     {
  197.     closed=0;
  198.     PlaySoundThing(stopsnd, door0, 1.0, 25, 50, 0);
  199.     SetSectorAdjoins(doorsec0, 0);
  200.     if(solved == 0)
  201.         {
  202.         SendMessageEx(hints, user3, 0, 0, 0, 0);    #param0=0; Reset.
  203.         }
  204.     return;
  205.     }
  206.     if((GetSenderRef() == door1) && (dr1_open == 2))
  207.     {
  208.     dr1_open=0;
  209.     SetSectorAdjoins(doorsec1, 0);
  210.     return;
  211.     }
  212.  
  213.  
  214.     return;
  215.  
  216. timer:
  217.     if(dr1_open == 1)
  218.     {
  219.     dr1_open=2;
  220.     MoveToFrame(switch1, 0, 1.0);
  221.     MoveToFrame(door1, 0, 0.8);
  222.     }
  223.     if(closed == 1)
  224.     {
  225.         if(in_jamb ==1)
  226.         {
  227.         closed=4;
  228.         MakeMeStop();
  229.         StartCutscene(0);
  230.  
  231.         vecZ = VectorSet(0.0, 0.0,1.0);
  232.         vecZneg = VectorSet(0.0, 0.0,-1.0);
  233.         MoveThing(door0, vecZneg, 0.12, 1.5);
  234.  
  235.         sleep(1.5);
  236.         PlayKey(player, hithead, 4, 0x12, 0);
  237.         PlayVoice(player, ungh, 1.0, 0);
  238.  
  239.         # Record some damage (yes, player can die this way)...
  240.         curhealth = GetThingHealth(player);
  241.         if(curhealth <= 40) return;
  242.         SetThingHealth(player, (curhealth - 40));
  243.  
  244.         MoveThing(door0, vecZ, 0.12, 1.5);
  245.         EndCutscene();
  246.         closed=1;
  247.         ClearActorFlags(player, 0x200000);
  248.         return;
  249.         }
  250.     closed=2;                        # Door is closing.
  251.     MoveToFrame(switch0, 0, 1.0);
  252.     MoveToFrame(door0, 0, 0.8);
  253.     }
  254.     return;
  255.  
  256. blocked:
  257.     if(GetSenderRef() == door0)
  258.     {
  259.     MoveToFrame(door0, 1, 0.8);
  260.     closed=1;
  261.     Return;
  262.     }
  263.     if(GetSenderRef() == door1)
  264.     {
  265.     MoveToFrame(door1, 1, 0.8);
  266.     dr1_open=1;
  267.     }
  268.     return;
  269.  
  270.  
  271. #=====================================================================
  272. #        Locked lines
  273. #=====================================================================
  274. randlocklines:
  275.  
  276.     while (dl_newline == dl_oldline)
  277.     {        
  278.         dl_newline = RandBetween(0, 19);
  279.         if (dl_newline < 14)
  280.         {    
  281.             dl_newline = RandBetween(0, 2); # ~1/4 chance for 0 thru 2
  282.         }
  283.  
  284.         if (dl_newline > 17)
  285.         {
  286.             dl_newline = (dl_newline - 13); # 1/20 chance for 5 or 6 
  287.         }    
  288.         if (dl_newline > 15)
  289.         {
  290.             dl_newline = 4; # 1/10 chance
  291.         }
  292.         if (dl_newline > 13)
  293.         {
  294.             dl_newline = 3; # 1/10 chance
  295.         }
  296.     }
  297.     dl_oldline = dl_newline;
  298.     lineindex = lockoffset + dl_newline;
  299.     speak0 = PlayVoice(player, in_stuck0[lineindex], 1.0, 0);
  300.     return;
  301.                     
  302. end
  303.  
  304.  
  305.